/**
 * Created by Ruzi on 2015/12/11.
 */



//1.判断服务器操作系统,ip地址,默认网关

function server_info(){
    var m;
    $.ajax({
        url:"1_server_info.php",
        type:"post",
        dataType:"json",
        async:false,
        success:function(e){
            m=e;
        }})
    return m;

}



//2.判断服务器的默认网关地址连接的设备

function device_info(url){
    var m;
    $.ajax({
        url:"2_deviceinfo.php",
        type:"post",
        dataType:"json",
        data:{url:url},
        async:false,
        success:function(e){
            m=e;

        }})
    return m;

}

//3.判断设备是否满足snmp网桥，托扑发现算法

function main_detect(url){
    var m;
    $.ajax({
        url:"3_main_detect.php",
        type:"post",
        dataType:"json",
        data:{url:url},
        async:false,
        success:function(e){
            m=e;

        }})
    return m;

}

//4.网络设备下的ip地址等信息
function net_device(url){
    var m;
    $.ajax({
        url:"4_net_device.php",
        type:"post",
        dataType:"json",
        data:{url:url},
        async:false,
        success:function(e){
            m=e;

        }})
    return m;

}

//5.查询网络设备下的设备信息
function check_topo_cap(url){
    var m;
    if(url!="") {
        $.ajax({
            url: "5_check_topo_cap.php",
            type: "post",
            dataType: "json",
            data: {url: url},
            async: false,
            success: function (e) {
                m = e;

            }
        });
    }
    return m;

}

//6.判断具有snmp功能的设备

function get_info(host,community){
    var info={};
    $.ajax({
        url:"get_info.php",
        type:"post",
        async:false,
        dataType:"json",
        data:{host:host,community:community},
        success:function(e){
            if(e.success) {

                var sysDesc = e.info["设备信息"][0]["sysDescr"];
                var sysName = e.info["设备信息"][0]["sysName"];
                //console.log("系统描述",sysDesc,"系统名称",sysName);
                var type="";

                if(sysDesc.indexOf("H3C")>=0){
                  //  console.log("includes1:",sysDesc.includes("Router"));

                    if(sysDesc.indexOf("Router")>=0){

                       // console.log("h3c Router");
                        type="Router";

                    }
                  if(sysDesc.indexOf("Switch")>=0){

                      //  console.log("h3c switch");
                        type="Switch";
                    }
                    if(sysDesc.indexOf("S5100-24P-EI")>=0){

                        //console.log("h3c switch");
                        type="h3c device";

                    }


                }else   if(sysDesc.indexOf("AirPort")>=0){
                    //AirPort
                    console.log(host,"AirPort");
                    type="AirPort";
                }

                info={success:true,ip:host,sysType:type,sysDecs:sysDesc,sysName:sysName};

            }else{

                info={success:true,ip:host,sysType:"",sysDecs:sysDesc,sysName:sysName};

            }


        },error:function(e){

        }

    });

    return info;

}




